#!/bin/sh
#
   TARNAME=dalton12.tar
   CTARNAME=$TARNAME.gz
#   TODAY=`date +%Y-%m-%d`
#
   echo
   echo "********************************** "
   echo "**** DALTON CVS EXPORT SCRIPT **** "
   echo "********************************** "
   echo
   echo "Check if logged in on CVS server..."
   LOGGEDIN=`cvs -Q status | grep "Working revision" | wc -l`
   while [ $LOGGEDIN -eq 0 ] ; do
	echo "You have to log in first:"
	cvs login
	LOGGEDIN=`cvs status | grep "Working revision" | wc -l`
   done
   echo " ...OK"
   echo "Checking for existence of dalton directory and archive..."
   if [ -s dalton ] ; then
	echo "The directory dalton already exists, cannot continue!"
	echo
	exit 1
   fi
   if [ -s $TARNAME ] ; then
	echo "The archive $TARNAME already exists, cannot continue!"
	echo
	exit 1
   fi
   if [ -s $CTARNAME ] ; then
	echo "The compressed archive $TARNAME.gz already exists, cannot continue!"
	echo
	exit 1
   fi
   echo " ...done"
   echo "Checking out files from CVS server (takes a while)..."
   cvs -Q export -r HEAD dalton
   echo " ...done"
   echo "Removing directories not part of release..."
   rm -rf dalton/Doc_cc
   rm -rf dalton/test_cc
   rm -rf dalton/tools/export
   echo " ...done"
   echo "Adding files to tar-achive..."
   tar cf $TARNAME dalton
   echo " ...done"
   echo "Compressing archive with gzip..."
   gzip --best $TARNAME
   echo " ...done"
   echo "Removing dalton directory..."
   rm -rf dalton
   echo " ...all done!"
   echo
